//
//  FinishedSubFooter.m
//  RRQS
//
//  Created by kyjun on 16/3/29.
//
//

#import "FinishedSubFooter.h"

@interface FinishedSubFooter ()

@property(nonatomic,strong) UIButton* btnIcon;
@property(nonatomic,strong) UILabel* labelSendAddress;

@end

@implementation FinishedSubFooter

-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if(self){         
        [self layoutUI];
        [self layoutConstraints];
    }
    return self;
}

#pragma mark =====================================================  user inferface layout
-(void)layoutUI{
    [self addSubview:self.btnIcon];
    [self addSubview:self.labelSendAddress];
}

-(void)layoutConstraints{
    self.btnIcon.translatesAutoresizingMaskIntoConstraints = NO;
    self.labelSendAddress.translatesAutoresizingMaskIntoConstraints = NO;
    CGFloat iconHeight = 25.f;
    
    [self.btnIcon addConstraint:[NSLayoutConstraint constraintWithItem:self.btnIcon attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:iconHeight]];
    [self.btnIcon addConstraint:[NSLayoutConstraint constraintWithItem:self.btnIcon attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:iconHeight]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.btnIcon attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0.f]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.btnIcon attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:10.f]];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelSendAddress attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0.f]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelSendAddress attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.f]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelSendAddress attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.btnIcon attribute:NSLayoutAttributeRight multiplier:1.0 constant:10.f]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelSendAddress attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.f]];
    
}

#pragma mark =====================================================  property package
-(void)setEntity:(MOrder *)entity{
    if(entity){
        _entity = entity;
        self.labelSendAddress.text = entity.address;
    }
}

-(UIButton *)btnIcon{
    if(!_btnIcon){
        _btnIcon = [UIButton buttonWithType:UIButtonTypeCustom];
        [_btnIcon setImage:[UIImage imageNamed:@"icon-sendStatus-light"] forState:UIControlStateNormal];
    }
    return _btnIcon;
}

-(UILabel *)labelSendAddress{
    if(!_labelSendAddress){
        _labelSendAddress = [[UILabel alloc]init];
        _labelSendAddress.numberOfLines = 0;
        _labelSendAddress.font = [UIFont systemFontOfSize:14.f];
    }
    return _labelSendAddress;
}


@end
